#include <unistd.h>
#include "vm.h"

#define FREQ_INTERVAL 16666 //microseconds - 60 hz
#define SLEEP_INTERVAL 1    //seconds

const size_t memory_sz = 64;

hardwareObject8* device8;

void controller() {
 wake:
  while (device8->active) {
    usleep(FREQ_INTERVAL);
    //if (!action()) { return; }
  }
  while (device8->active = -1) { sleep(SLEEP_INTERVAL); }
  if (!device8->active) { return; }
  goto wake;
}

void vsleep() { device8->active = -1;   }
void wake()  { device8->active = TRUE; }

bool detach() {}
bool attach() {}

//bool recv8(int8_t data) {}
//bool recv16(int16_t data) {}
